function [x,output]=conssolve_het(x0,phinew,Y,margut_lag,rhovec_long);
objval = [];
output=[];
options = optimset('LargeScale','off','Display','off','TolX',0.0001);
[x,fval,exitflag]=fsolve(@objfun,x0,options);
output(1)=exitflag;
output(2)=max(abs(fval));
function f = objfun(x);
margut=x.^(-rhovec_long);
f(1:size(margut,2)-1)=(margut(:,2:end)./margut(:,1)).^(-1)-((1+phinew(:,2:end))./(1+phinew(:,1))).*(margut_lag(:,2:end)./margut_lag(:,1)).^(-1);
f(size(margut,2))=sum(x)-Y;
end

end